﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using XLua;

#region Lesson1
//无命名空间的自定义类
public class Test
{
    public void Speak(string s)
    {
        Debug.Log("Test"+s);
    }
}
//有命名空间的自定义类
namespace LCC
{
    public class Test2
    {
        public void Speak(string s)
        {
            Debug.Log("Test2"+s);
        }
    }
}

#endregion

#region Lesson2

public enum MyEnum
{
    Idle,
    Move,
    Attack
}

#endregion

#region Lesson3

public class Lesson3
{
    public int[] array = new [] {1, 3, 5, 7, 9};

    public List<int> list = new List<int>();

    public Dictionary<string, int> dic = new Dictionary<string, int>();
}

#endregion

#region Lesson4

[LuaCallCSharp]
public static class Tool
{
    public static void Move(this Lesson4 obj)
    {
        Debug.Log("Move"+obj.name);
    }
}

[LuaCallCSharp]
public class Lesson4
{
    public string name = "胡宇辰";

    public void Speak(string str)
    {
        Debug.Log(str);
    }

    public static void Eat()
    {
        Debug.Log("吃东西");
    }
}

#endregion

#region Lesson5

public class Lesson5
{
    public int RefFunc(int a, ref int b, ref int c, int d)
    {
        Debug.Log(b+" "+c);
        b = a + d;
        c = a - d;
        return 100;
    }

    public int OutFunc(int a, out int b, out int c, int d)
    {
        b = a;
        c = d;
        return 200;
    }

    public int RefOutFunc(int a, out int b, ref int c)
    {
        Debug.Log(c);
        b = a * 10;
        c = a * 20;
        return 300;
    }
}

#endregion

#region Lesson6

public class Lesson6
{
    public int Calc()
    {
        return 100;
    }

    public int Calc(int a, int b)
    {
        return a + b;
    }

    public int Calc(int a)
    {
        return a;
    }

    public string Calc(string a)
    {
        return a;
    }
}

#endregion

#region Lesson7
[CSharpCallLua]
public delegate string MyFunc(int i);

public class Lesson7
{
    public UnityAction action;
    public MyFunc func;
    //不能用自带的Func 因为没有[CSharpCallLua] Lua无法识别
    public event UnityAction eventFunc;

    public void DoEvent()
    {
        if (eventFunc != null)
        {
            eventFunc();
        }
    }
}

#endregion

#region Lesson8

public class Lesson8
{
    public int[,] nums = new int[2, 3] {{1, 2, 3}, {4, 5, 6}};
}

#endregion

#region Lesson9

[LuaCallCSharp]
public static class Lesson9
{
    public static bool IsNull(this UnityEngine.Object obj)
    {
        return obj == null;
    }
}

#endregion

#region Lesson10

public static class Lesson10
{
    //需要XLua生成
    [CSharpCallLua]
    public static List<Type> CCL = new List<Type>()
    {
        //typeof(UnityAction<float>),
        typeof(UnityAction<bool>)
    };
    
    [LuaCallCSharp()]
    public static List<Type> LCC = new List<Type>()
    {
        //typeof(GameObject),
        //typeof(Rigidbody)
    };
}
#endregion

#region Lesson12

public class Lesson12
{

}

#endregion
public class LuaCallCSharp : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Toggle toggle;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
